import request from '@/utils/request'

export function getDictPagedList(query) {
  return request({
    url: `/api/business/dicts_admin/`,
    method: 'get',
    params: query
  })
}

export function getDictForEdit(id) {
  return request({
    url: `/api/business/dicts_admin/${id}/`,
    method: 'get'
  })
}

export function createDict(data) {
  return request({
    url: `/api/business/dicts_admin/`,
    method: 'post',
    data
  })
}

export function updateDict(id, data) {
  return request({
    url: `/api/business/dicts_admin/${id}/`,
    method: 'put',
    data
  })
}

export function deleteDict(id) {
  return request({
    url: `/api/business/dicts_admin/${id}/`,
    method: 'delete'
  })
}

export function changeDisplayOrder(id, data) {
  return request({
    url: `/api/business/dicts_admin/${id}/change_display_order/`,
    method: 'put',
    data
  })
}

export function getDictItemPagedList(query) {
  return request({
    url: `/api/business/dicts_admin/items/`,
    method: 'get',
    params: query
  })
}

export function getDictItem(id) {
  return request({
    url: `/api/business/dicts_admin/items/${id}/`,
    method: 'get'
  })
}

export function createDictItem(data) {
  return request({
    url: `/api/business/dicts_admin/items/`,
    method: 'post',
    data
  })
}

export function updateDictItem(id, data) {
  return request({
    url: `/api/business/dicts_admin/items/${id}/`,
    method: 'put',
    data
  })
}

export function deleteDictItem(id) {
  return request({
    url: `/api/business/dicts_admin/items/${id}/`,
    method: 'delete'
  })
}

export function changeItemDisplayOrder(id, data) {
  return request({
    url: `/api/business/dicts_admin/items/${id}/change_display_order/`,
    method: 'put',
    data
  })
}

export function changeActive(id, data) {
  return request({
    url: `/api/business/dicts_admin/items/${id}/change_active/`,
    method: 'put',
    data
  })
}

export function getDictList(query) {
  return request({
    url: `/api/business/dicts/`,
    method: 'get',
    params: query
  })
}
